package com.hisense.ovcloud.warehouse.config;

import io.swagger.v3.oas.models.info.Info;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OpenApiGroupConfig {
    @Bean
    public GroupedOpenApi warehouseOpenApi(@Value("${springdoc.version}") String appVersion) {
        String[] paths = { "/ac-julink-warehouse/**" };
        return GroupedOpenApi.builder().group("ac-julink-warehouse")
                .addOpenApiCustomiser(openApi -> openApi.info(new Info().title("ac-julink-warehouse API").version(appVersion)))
                .pathsToMatch(paths)
                .build();
    }

    @Bean
    public GroupedOpenApi productOpenApi(@Value("${springdoc.version}") String appVersion) {
        String[] paths = { "/ac-product/**" };
        return GroupedOpenApi.builder().group("ac-product")
                .addOpenApiCustomiser(openApi -> openApi.info(new Info().title("ac-product API").version(appVersion)))
                .pathsToMatch(paths)
                .build();
    }

    @Bean
    public GroupedOpenApi platformOpenApi(@Value("${springdoc.version}") String appVersion) {
        String[] paths = { "/ac-platform/**" };
        return GroupedOpenApi.builder().group("ac-platform")
                .addOpenApiCustomiser(openApi -> openApi.info(new Info().title("ac-platform API").version(appVersion)))
                .pathsToMatch(paths)
                .build();
    }

    @Bean
    public GroupedOpenApi basicDataOpenApi(@Value("${springdoc.version}") String appVersion) {
        String[] paths = { "/basic-data/**" };
        return GroupedOpenApi.builder().group("basic-data")
                .addOpenApiCustomiser(openApi -> openApi.info(new Info().title("basic-data API").version(appVersion)))
                .pathsToMatch(paths)
                .build();
    }
}
